package net.sky.oa.dao.talkpark.impl;

import java.util.List;
import org.springframework.stereotype.Repository;
import net.sky.oa.dao.SkyBaseDaoImpl;
import net.sky.oa.dao.talkpark.MailFolderDao;
import net.sky.oa.model.MailFolder;

@SuppressWarnings("unchecked")
@Repository
public class MailFolderDaoImpl extends SkyBaseDaoImpl<MailFolder> implements MailFolderDao {
	
	public MailFolderDaoImpl(){
		super.setPersistType(MailFolder.class);
	}

	public List<MailFolder> findAllMailFolder() {
	    String hql="from MailFolder mf";
		return findByHql(hql);
	}
	
	public List<MailFolder> getAllUserFolderByParentId(Long userId, Long parentId){
		String hql="from MailFolder mf where mf.user.id=? and mf.parentid=? or mf.user.id is null";
		return findByHql(hql,new Object[]{userId,parentId});
	}
	
	public List<MailFolder> getUserFolderByParentId(Long userId, Long parentId){
		String hql="from MailFolder mf where mf.user.id=? and mf.parentid=?";
		return findByHql(hql,new Object[]{userId,parentId});
	}

}
